<template>
  <div>
    <van-nav-bar
      title="订单页"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-card
      v-for="(item, index) in orderlist"
      :key="index"
      :price="item.price"
      :title="item.movieTitle"
      :thumb="item.imgUrl"
    >
      <template #footer>
        <van-button
          plain
          hairline
          type="info"
          v-if="item.ispin === 0"
          @click="toPublished(item.idref,item.id)"
          >评价</van-button
        >
        <van-button plain hairline type="info" v-else>已评价</van-button>
      </template>
    </van-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      orderlist: [],
    };
  },
  created() {
    this.getOrderlist();
  },
  methods: {
    async getOrderlist() {
      const { data: res } = await this.$http.get("/order");
      if (res.status !== 200) return this.$message.fail("获取订单失败");
      this.orderlist = res.data;
    },
    onClickLeft() {
      this.$router.back();
    },
    toPublished(idref,id) {
      this.$router.push({
        path: "/published",
        query: {
          idref,
          id
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.textScroll {
    display: inline-block;
    position: fixed;
    top:0;
    bottom: 0;
    overflow: scroll;
    right: 0;
    width: 100%;
    margin-bottom: 50px;
    z-index: 1;
    background-color:rgb(241,243,244);
  }
</style>